#pragma once
#include <string>
#include <map>
#include <sys/sys_asy.h>
#include <list>
#include <interface/aot_im_interface.h>

class chat_mgr
{
	struct chat_info_t
	{
		chat_info_t()
		{
			wnd = NULL;
		}
		std::list<std::string> call_id_lst;
		HWND wnd;
	};
	/// <tata inner_id, chat_info_t>
	typedef std::map<aot_innerid_t, chat_info_t> map_type;
	typedef xy::auto_lock<xy::thread_mutex> auto_lock_type;
public:
	chat_mgr();
	~chat_mgr();
public:
	bool insert(aot_innerid_t peer_user_id, HWND wnd, const char* call_id);
	void remove_call_id(aot_innerid_t peer_user_id, const char* call_id);
	void remove_all(bool destroy_wnd = false);
	std::string find_call_id(aot_innerid_t peer_user_id);
	std::string find_call_id_and_add(aot_innerid_t peer_user_id);
	HWND find_wnd(aot_innerid_t peer_user_id);
	bool set_wnd(aot_innerid_t peer_user_id, HWND wnd);
public:
	xy::thread_mutex mutex_;
	map_type map_;
};
